{include file="public_iframe:head"}
<link href="__STATIC__/admin/css/plugins/iCheck/custom.css" rel="stylesheet">
<link href="__STATIC__/admin/css/plugins/steps/jquery.steps.css" rel="stylesheet">
<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>基础表单向导</h5>
                    </div>
                    <div class="ibox-content">
                        <div id="wizard">
                            <h1>选择数据类别</h1>
                            <div class="step-content">
                                    <div class="form-group">
                                      <div class="col-sm-6">
                                        {volist name='loan_level' id='vo'}
                                            <label class="checkbox-inline">
                                                <input type="radio" name="level_id"  value="{$vo['id']}"  >{$vo['name']}<br/>剩余：{$vo['num']}条<br/>价格：{$vo['price']}&nbsp;元/条
                                            </label>
                                        {/volist}
                                      </div>
                                    </div>
                            </div>

                            <h1>数据条数</h1>
                            <div class="step-content">
                                <div class="text-center">
                                    <input type="number" name="account" class="form-control" min="0" value="0">
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        </div>
    </div>
    <!-- Steps -->
    <script src="__STATIC__/admin/js/plugins/staps/jquery.steps.min.js"></script>

    <script>
        var index_lay_msg;
        $(document).ready(function () {
            $("#wizard").steps(); 

            $('.actions ul li').eq('2').find('a').text('导出数据');

            $('.actions ul li').eq('2').click(function(){
                    var account = $('input[name="account"]').val();
                    var level_id = $('input[name="level_id"]:checked').val();

                    if(typeof(level_id) == 'undefined'){
                        parent.layer.alert('请选择数据类别!',{
                          skin: 'layui-layer-molv' //样式类名
                          ,closeBtn: 0
                        });
                        return false;
                    }

                    if(account < 0 || account == 0){
                        var index = parent.layer.alert('请输入正确数据', {
                            skin: 'layui-layer-molv' //样式类名
                            ,closeBtn: 0
                        }, function(){
                          parent.layer.close(index);
                        });
                        return false;
                    }
                    
                    var formData = new FormData();

                    formData.append('account',account);
                    formData.append('level_id',level_id);

                    $.ajax({
                      url:"{:url('Resource/index')}",
                      type:'POST',
                      data:formData,
                      async:true,
                      processData:false,
                      contentType:false,
                      beforeSend: function(){  
                           ityzl_SHOW_LOAD_LAYER();
                      }, 
                      success:function(result){
                          if(result.code == '0'){
                              parent.layer.alert(result.msg,{
                                skin: 'layui-layer-molv' //样式类名
                                ,closeBtn: 0
                              });
                          }else{
                              parent.layer.close(index_lay_msg);
                              location.href="/member/resource/export/account/"+account+"/level_id/"+level_id+'.html';
                          }
                      }
                    });
            });

            //删除第三步
            $('.actions ul li').eq('3').remove();  
        });

        function ityzl_SHOW_LOAD_LAYER(){
            index_lay_msg = parent.layer.msg('导出中...', {icon: 16,shade: [0.5, '#f5f5f5'],scrollbar: false,offset: '0px', time:1800*1000}) ;  
        }
    </script>
</body>